package com.yunji.base.mapper;

import com.github.yulichang.base.MPJBaseMapper;
import com.yunji.base.dto.StaffFiledDTO;
import com.yunji.common.annotation.DataScope;
import com.yunji.common.model.domain.StaffDO;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @Package com.yunji.user.mapper
 * FileName:	StaffMapper.java
 * Copyright:	Copyright © 2024 云集互联 All Rights Reserved
 * Company:		云集互联
 * @version: 1.0
 * @since: JDK 1.8.0_202
 * Create at:   2024-04-07 02:09:44
 * Description:
 * 员工信息
 * Modification History:
 * Author					Date					Version         Description
 * -------------------------------------------------------------------------------------
 * HuaAo0803@163.com	2024-04-07 02:09:44     1.0             1.0 Version
 */
public interface IStaffMapper extends MPJBaseMapper<StaffDO> {

    @DataScope
    @Select({"<script>SELECT DISTINCT ${searchFiled} FROM staff s LEFT JOIN v3_belong b ON s.belong_id = b.belong_id",
            " LEFT JOIN s_agent_user au ON b.agent_id = au.id LEFT JOIN t_site ts ON b.site_id = ts.id WHERE s.del_flag=0 AND b.del_flag=0",
            "<if test='agentId != null'>AND b.agent_id = #{agentId}</if>",
            "<if test='siteId != null'>AND b.site_id = #{siteId}</if>",
            "<if test='staffName != null'>AND s.staff_name LIKE concat('%',#{staffName},'%')</if>",
            "<if test='staffTel != null'>AND s.staff_tel LIKE concat('%',#{staffTel},'%')</if>",
            "<if test='agentName != null'>AND au.agent_name LIKE concat('%',#{agentName},'%')</if>",
            "<if test='siteName != null'>AND ts.site_name LIKE concat('%',#{siteName},'%')</if></script>"})
    List<String> searchTableField(StaffFiledDTO param);
}
